<?php
$uname = $_REQUEST['uname'] ;
$uemail = $_REQUEST['uemail'] ;
$femail = $_REQUEST['femail'] ;
$fname = $_REQUEST['fname'] ;
$song = $_REQUEST['song'].'.mp3';
$song2 = str_replace(" ", "%20", "$song");


include('./init.php');
$res = mysql_query("SELECT file_title, file_name FROM bj_audio WHERE file_name='". mysql_real_escape_string($song) . "'") or die(mysql_error());
//echo "SELECT file_title, file_name FROM bj_audio WHERE file_name='". mysql_real_escape_string($song) . "'";
if ($res !== FALSE && mysql_num_rows($res)) {
  $lin = mysql_fetch_assoc($res);
}

// /Thank you page after successful submission
//$tpage = "http://televisiontunes.com/player.php?song=$song";
$tpage = utils::create_href($lin['file_title']);
//$a = str_replace('.mp3', '', $lin['file_name']);
//$tpage = '&lt;a href="' . utils::create_href($lin['file_title']) .'"&gt;' . $a . '&lt;/a&gt;';

// Change the subject text below to suit
$usubject = "$fname wants you to listen to this theme song.";

// Change the text below for the email
$utext = "Hi,

Your friend $uname, wants you to listen to $song on TelevisionTunes.com.

Listen to it here {$tpage} or check out more theme songs at www.TelevisionTunes.com

Enjoy!";
# This sends the email to the addresses entered
@mail($femail, $usubject, $utext, "FROM: $uemail");

# After submission, the target of Thank You page.
//header("Location: $tpage");
echo 'DONE';
exit();
?>